package controllers;

import java.util.List;

import models.entities.Colonia;
import models.services.ServicioColonias;
import models.services.exc.EntityNotFoundException;

public class ControladorColonias {

	public Colonia obtenerColoniaPorId(int id) {
		ServicioColonias service = new ServicioColonias();
		Colonia col = null;
		try {
			col = service.obtener(id);
		} catch (EntityNotFoundException enf) {
			System.out.println("Colonia no encontrada");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return col;
	}

	public List<Colonia> obtenerTodasLasColonias() {
		ServicioColonias service = new ServicioColonias();
		return service.obtenerListaDeColonias();
	}
	
	public void crearColonia(Colonia col){
		ServicioColonias servicio = new ServicioColonias();
		int ret = servicio.guardarActualizar(col);
		System.out.println("resultado: "+ret);
	}
	
	public int actualizarColonia(String campo, String value, int id) {
		ServicioColonias service = new ServicioColonias();
		return service.update(campo, value, id);
	}

	public int actualizarColonia(String campo, int value, int id) {
		ServicioColonias service = new ServicioColonias();
		return service.update(campo, value, id);
	}

}
